﻿<%@ Page Title="" Language="vb" AutoEventWireup="false" MasterPageFile="~/Site.Master" CodeBehind="EditQuiz.aspx.vb" Inherits="Assignment4.EditQuiz" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    <style type="text/css">
        .style1
        {
            width: 100%;
        }
        .style2
        {
            height: 6px;
        }
    </style>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">

<script src="../development-bundle/jquery-1.4.4.js" type="text/javascript"></script>
    <script src="../jQuery/jquery-ui-1.8.10.custom.min.js" type="text/javascript"></script>
    <script src="../tag-it-master/js/tag-it.js" type="text/javascript"></script>

    <link href="../development-bundle/themes/base/jquery.ui.all.css" rel="stylesheet"
        type="text/css" />

    <link href="../tag-it-master/css/jquery.tagit.css" rel="stylesheet" type="text/css" />

    <script type="text/javascript">
        $(function () {

            var availableTags = $("#<%= hdnDBTags.ClientID %>").val().split(',');

            $('#quiztags').tagit({ tagSource: availableTags, select: true });

            $("#<%= btnUpdate.ClientID %>").click(function () {

                getTagsString($('#quiztags').tagit('assignedTags'))
            });

            function getTagsString(tags) {
                $("#<%= hdnSelectedTags.ClientID %>").val($('#quiztags').tagit('assignedTags'));
            }
        });
</script>

<asp:HiddenField ID="hdnDBTags" runat="server" />
<asp:HiddenField ID="hdnSelectedTags" runat="server" />
    <h2>Edit My Quizes</h2>
   
   
    <asp:GridView ID="grvQuiz" runat="server" AutoGenerateColumns="False" 
        DataKeyNames="QuizId" DataSourceID="SqlDataSourceGetQuizes" 
        AllowPaging="True" AllowSorting="True" CellPadding="4" ForeColor="#333333" 
        GridLines="None" PageSize="5" Width="405px">
        <AlternatingRowStyle BackColor="White" ForeColor="#284775" />
        <Columns>
            <asp:BoundField DataField="QuizName" HeaderText="Name" 
                SortExpression="QuizName" />
             <asp:TemplateField>
             <ItemTemplate>
              <%# getDate(Eval("QuizDate"))%>
             </ItemTemplate> 
            </asp:TemplateField>
              <asp:TemplateField>
             <ItemTemplate>
               <img class="gridpicture" src="<%# getPicture(Eval("QuizPicture"))%>" />
                  
             </ItemTemplate> 
            </asp:TemplateField>
            <asp:HyperLinkField DataNavigateUrlFields="QuizId" 
                DataNavigateUrlFormatString="EditQuiz.aspx?QuizId={0}" Text="Edit Quiz" />
            <asp:HyperLinkField DataNavigateUrlFields="QuizId" 
                DataNavigateUrlFormatString="EditQuizQuestion.aspx?QuizId={0}" 
                Text="Edit Quiz Questions" />
        </Columns>
        <EditRowStyle BackColor="#999999" />
        <FooterStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <HeaderStyle BackColor="#5D7B9D" Font-Bold="True" ForeColor="White" />
        <PagerStyle BackColor="#284775" ForeColor="White" HorizontalAlign="Center" />
        <RowStyle BackColor="#F7F6F3" ForeColor="#333333" />
        <SelectedRowStyle BackColor="#E2DED6" Font-Bold="True" ForeColor="#333333" />
        <SortedAscendingCellStyle BackColor="#E9E7E2" />
        <SortedAscendingHeaderStyle BackColor="#506C8C" />
        <SortedDescendingCellStyle BackColor="#FFFDF8" />
        <SortedDescendingHeaderStyle BackColor="#6F8DAE" />
    </asp:GridView>
    <asp:SqlDataSource ID="SqlDataSourceGetQuizes" runat="server" 
        ConnectionString="<%$ ConnectionStrings:learningConnectionString %>" 
        ProviderName="<%$ ConnectionStrings:learningConnectionString.ProviderName %>" 
        SelectCommand="SELECT * FROM [Quizes] WHERE ([UserId] = ?)">
        <SelectParameters>
            <asp:CookieParameter CookieName="userIdCookie" Name="UserId" Type="Int32" />
        </SelectParameters>
    </asp:SqlDataSource>
    <asp:Panel ID="pnlFields" runat="server">
    
    <br />
    <table class="style1">
        <tr>
            <td>
                Name</td>
            <td>
                <asp:TextBox ID="txtName" runat="server"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" 
                    ControlToValidate="txtName" CssClass="lblmessage" ErrorMessage="Enter Name" 
                    ValidationGroup="update">*</asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td>
                Description</td>
            <td>
                <asp:TextBox ID="txtDescription" runat="server" Height="66px" 
                    TextMode="MultiLine" Width="695px"></asp:TextBox>
                <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" 
                    ControlToValidate="txtDescription" CssClass="lblmessage" 
                    ErrorMessage="Enter Description" ValidationGroup="update">*</asp:RequiredFieldValidator>
            </td>
        </tr>
        <tr>
            <td class="style2">
                Picture</td>
            <td class="style2">
                <asp:FileUpload ID="fuImage" runat="server" />
            </td>
        </tr>
        <tr>
            <td>
                Tags</td>
            <td>
                <ul id="quiztags" name="nameOfSelect">
                    <asp:Literal ID="ltrTags" runat="server"></asp:Literal>
                </ul>
           </td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
            <td>
                <asp:ValidationSummary ID="ValidationSummary1" runat="server" 
                    CssClass="lblmessage" ValidationGroup="update" />
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
            <td>
                <asp:Button ID="btnUpdate" runat="server" Text="Update" 
                    OnClick="btnUpdate_Quiz" ValidationGroup="update" />
            </td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
            <td>
                &nbsp;</td>
        </tr>
        <tr>
            <td>
                &nbsp;</td>
            <td>
                <asp:Label ID="lblMessage" runat="server" Text=""></asp:Label>
            </td>
        </tr>
    </table>
    </asp:Panel>
    <br />
</asp:Content>
